@extends('admin.layout.common')
@section('content')
    <link rel="stylesheet" type="text/css" href="{{URL::asset('css/app.css')}}">
    <link rel="stylesheet" type="text/css" href="{{URL::asset('css/user/AgencyStatistics.css')}}">
    <style>
        form{
            position:relative;
        }
        #simple_name-error{
            position: absolute;
            top:80px;
            left:100px;
        }
        #phone_name-error{
            position: absolute;
            top:80px;
            left:374px;
        }
        #fix_date-error{
            position:absolute;
            top:80px;
            left:651px;
        }
        #agent_type-error{
            position:absolute;
            top:80px;
            left:960px;
        }
        #main-error{
            position:absolute;
            top:80px;
            left:1242px;
        }
        #count-error{
            position: absolute;
            top:160px;
            left:374px;
        }
        .error{
            color:red;
        }
    </style>
    <div class="content_bigbox">
        <div class="content">
            <div class="mon">
                <div class="mon_left">
                    <p>
                        <i class="iconfont icon gongzuo">&#xe647;</i>
                        <span>{{date('Y年m月d日')}}  本月已开户{{ session('monthPass') }}个  打回{{session('monthRefuse')}}个</span>
                    <p>超过了{{ session('monthPrecent') }}的三咖审核员，继续努力！从此踏上人生巅峰，迎娶白富美！</p>
                    </p>
                </div>
                <div class="mon_right">
                    <p>您今天已经开户{{session('todayPass')}}个    打回{{session('todayRefuse')}}个</p>
                    <p>超过了{{session('todayPrecent')}}的三咖开户员哦~棒棒哒！！！</p>
                </div>
            </div>
            <p class="tongzhi"><i class="iconfont icon laba">&#xe914;</i>{{getArticleByDepartmentId()}}</p>
            <!-- 公共结束 -->
        </div>
        <div class="content_bottom_box">
            <form method="get" class="cmxform" id="signupForm" action="{{url('/admin/agentList')}}">
                {{csrf_field()}}
                <label for="simple_name">代理简称：<input id="simple_name" type="text" name="simple_name" placeholder="请输入代理简称"></label>
                <label for="phone_name">联系人：<input id="phone_name" type="text" name="phone_name" placeholder="请输入联系人"></label>
                <label for="fix_date">签约日期:<input id="fix_date" type="date" name="fix_date"></label>
                <label for="">代理性质选择</label>
                <select name="agent_type">
                    <option value="">--请选择--</option>
                    <option value="1">录音棚</option>
                    <option value="2">cp公司</option>
                    <option value="3">业内达人</option>
                    <option value="4">老师</option>
                    <option value="5">制作人</option>
                    <option value="6">独立音乐人</option>
                    <option value="7">乐手</option>
                    <option value="8">词曲人</option>
                    <option value="9">媒体人</option>
                    <option value="10">自媒体</option>
                    <option value="11">正规媒体</option>
                    <option value="12">软件渠道</option>
                    <option value="13">网红达人</option>
                    <option value="14">经纪人</option>
                </select>
                <label for="">主营业员选择</label>
                <select name="main">
                    <option value="">--请选择--</option>
                    <option value="无">无主营业员</option>
                    @foreach($sale as $v)
                        <option value="{{$v['name']}}">{{$v['name']}}</option>
                    @endforeach
                </select>
                <button type="submit" name="" class="submit" value="筛选">筛选</button><br/>
                <label for="">代理状态：
                    <input type="radio" name="status" class="radio_input" value="0"><label>正常</label>
                    <input type="radio" name="status" class="radio_input" value="2"><label>暂停使用</label>
                </label>
                <label for="count" style="margin-left:10px;">代理数量：</label>
                <select name="count">
                    <option value="">--请选择--</option>
                    <option value="asc">升序</option>
                    <option value="desc">降序</option>
                </select>
                <label for="expired"><input type="radio" name="expired" class="radio_input" value="1">签约已到期</label>
                <label for="expired"><input type="radio" name="expired" class="radio_input" value="2">签约1个月内到期</label>
                <button type="button" name="" value="导出EXcel" class="daochu" onclick="exportExcel()">导出EXcel</button>
            </form>
            <table border="1" width="100%">
                <tr>
                    <th>ID</th>
                    <th>代理简称</th>
                    <th>性质</th>
                    <th>联系人</th>
                    <th>主营业员</th>
                    <th>签约日期</th>
                    <th>代理数量</th>
                    <th>代理状态</th>
                    <th>操作</th>
                </tr>
                @foreach($list as $v)
                    <tr>
                        <td>{{$v->id}}</td>
                        <td>{{$v->simple_name}}</td>
                        <td>{{$v->agent_type}}</td>
                        <td>{{$v->phone_name}}</td>
                        <td>{{$v->main}}</td>
                        <td>{{$v->fix_date}}</td>
                        <td>{{$v->users_info_count}}</td>
                        <td>
                            @switch($v->status)
                                @case (1)
                                    注销
                                    @break
                                @case (2)
                                    正常
                                    @break
                                @case (3)
                                    暂时停用
                                    @break
                            @endswitch
                        </td>
                        <td>
                            <button type="button" value="查看" class="look" onclick="javascript:window.location.href='{{url('admin/agentDetail/'.$v->id)}}'">查看</button>
                        </td>
                    </tr>
                @endforeach
            </table>
            <div class="bottom" style="margin-top: 40px">
                <style>.pagination{float:right;margin-top:40px;margin-right:100px}</style>
                {{$list->appends([
                    'count' => $_GET['count'] ?? '',
                    'simple_name' => $_GET['simple_name'] ?? '',
                    'status' => $_GET['status'] ?? '',
                    'phone_name' => $_GET['phone_name'] ?? '',
                    'fix_data' => $_GET['fix_data'] ?? '',
                    'agent_type' => $_GET['agent_type'] ?? '',
                    'main' => $_GET['main'] ?? '',
                    'expired' => $_GET['expired'] ?? '',
                ])->links()}}
                <div id="test1" style="font-size:20px;text-align: center;margin-bottom:0px"></div>
            </div>
        </div>
    </div>
<script>
  function exportExcel() {
    window.location.href = '{{url('/admin/exportAgentList')}}';
    {{--$.ajax({--}}
      {{--url: '{{url('/admin/exportAgentList')}}',--}}
      {{--method: 'POST',--}}
      {{--data: {--}}
        {{--_token: '{{csrf_token()}}',--}}
      {{--},--}}
      {{--success: function (data) {--}}
        {{--console.log(data);--}}
      {{--}--}}
    {{--})--}}
  }
    /*$().ready(function() {
        $("#signupForm").validate({
            rules: {
                simple_name: {
                    required:true,
                    minlength: 5
                },
                phone_name: {
                    required:true,
                    minlength: 2
                },
                fix_date:{
                    required:true,
                }
            },
            messages: {
                simple_name: {
                    required: "请输入代理简称",
                    minlength:"长度不能小于 5 个字符"
                },
                phone_name: {
                    required: "请输入联系人",
                    minlength:"长度不能小于 2 个字符"
                },
                fix_date:{
                    required:"请选择日期",
                }
            }
        });
    })*/
</script>
@endsection
